#if !defined(__FILE_TOOLS_H)
#define __FILE_TOOLS_H

#define MOUNT_LIST_MAX 4

typedef uint32_t (*files_to_cb_t)(uint8_t *buff, uint32_t len, void *user_data);

typedef struct find_file
{
    struct find_file *next;
    struct find_file *last;
    char path[];
} find_file_s, *find_file_t;

void find_file_free(find_file_t list);

#define FIND_FILE 1
#define FIND_DIR 2
#define FIND_ALL FIND_FILE | FIND_DIR

find_file_t find_files_get_p(char *src_dir, const char **names, find_file_t p);
find_file_t find_files_type_get_p(char *src_dir, const char **names, uint8_t type, find_file_t p);
find_file_t find_files_type_name_get_p(char *src_dir, const char **names, uint8_t type, bool (*check_name_cb)(char *str, char *str2, uint8_t len), find_file_t p);
bool list_files(char *src_dir, int max_deepin);
bool list_dirs(char *src_dir, int max_deepin);
bool find_files(char *src_dir, const char **names);

uint32_t list_files_to_buffer(char *path, char *buffer, unsigned int len);
uint32_t find_files_to(char *src_dir, const char **names, char *to, unsigned int to_len);
uint32_t find_name_to(char *src_dir, const char *name, char *to, unsigned int to_len);
uint32_t list_files_to(char *path, char *buffer, unsigned int len);

// uint32_t find_files_to(char *src_dir, const char **names, char *to, unsigned int to_len);
uint32_t find_name_to_cb(char *src_dir, const char *name, uint8_t *buff, uint32_t send_len, files_to_cb_t cb, void *user_data);
uint32_t list_files_to_cb(char *path, files_to_cb_t cb, void *user_data);

bool mkdirs(char *muldir);
bool file_exist(const char *path);
bool dir_exist(const char *path);
uint8_t *file_get_md5(char *path);
char *file_get_md5_str(char *path);

char *get_hex_str(const uint8_t *buffer, uint8_t len);
void file_tool_add_mount(char *path);
void file_tool_del_mount(char *path);
#endif // __FILE_TOOLS_H
